#查找最大子积 [-1,4,-1]  -->4  [-1,2,4,-1] -->8  [-1,2,3,4,-1] -->24

def Maxmulti(nums):
    length = len(nums)
    multi = []
    multi.append(nums[0])
    a = 0
    while a < length - 1:
        b = a * (a + 1) // 2
        for i in range(1+a,length):
            multi.append(nums[i] * multi[i+a*length-1-b])
        multi.append(nums[1+a])
        a += 1

    return max(multi)

print(Maxmulti([-2,8,-1,10,-3,1]))


#百度了一下别的方法

# def maxProduct(nums):
#
#     length = len(nums)
#     dpmax = [0 for _ in nums]
#     dpmin = [0 for _ in nums]
#
#     dpmax[0] = nums[0]
#     dpmin[0] = nums[0]
#     for i in range(1, length):
#         dpmax[i] = max(nums[i], max(nums[i] * dpmax[i - 1], nums[i] * dpmin[i - 1]))
#         dpmin[i] = min(nums[i], min(nums[i] * dpmax[i - 1], nums[i] * dpmin[i - 1]))
#
#     return max(dpmax)
#
# print(maxProduct([-4,2,4,4,-3,-2]))
